package com.shengzai.mapreduce.text2;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * 需求：
 *      将学生的总分和基本信息数据进行读取，并且将大于450分的学生输出到一个文件中，
 *          并且小于等于450分的数据写入另一个文件中，并且不要 ReduceTask
 *
 */
public class OutputMapper extends Mapper<LongWritable, Text,Text, NullWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, NullWritable>.Context context) throws IOException, InterruptedException {
        // 1500100002	吕金鹏,24,男,文科六班,440
        String[] split = value.toString().split("\t");
        String studentID = split[0];
        String[] columns = split[1].split(",");
        String name = columns[0];
        String age = columns[1];
        String gender = columns[2];
        String clazz = columns[3];
        String score = columns[4];

        context.write(new Text(studentID+","+name+","+age+","+gender+","+clazz+","+score),NullWritable.get());

    }
}
